package org.carl.code.ext;

import cn.hutool.core.io.file.FileNameUtil;
import org.carl.code.Generate;

import java.io.File;

public class Java extends Generate {


    public Java(File sourceFile, File targetFile) {
        super(sourceFile, targetFile);
    }

    @Override
    public void generate() {
        fillTargetFile(true,content->{
            String oldFileName = FileNameUtil.mainName(sourceFile);
            String newFileName = FileNameUtil.mainName(targetFile);
            //替换文中的关键字
            return content.replaceAll(oldFileName,newFileName)
                    //替换首字母大写关键字
                    .replaceAll(upperFirstLatter(sourceName.get()),upperFirstLatter(targetName.get()));
        });
    }
}
